package keeto.com.vn.classified.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.classified.core.ClassifiedCore;
import keeto.com.vn.classified.core.ClassifiedListener;
import keeto.com.vn.classified.network.IProtocol;
import keeto.com.vn.classified.request.ForgetPassRequest;
import keeto.com.vn.classified.response.ForgotPassResponse;

public class TaskForgotPass extends AbstractTask{
	String email;
	public TaskForgotPass(ClassifiedListener listener, ClassifiedCore core, String email) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.email=email;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		ForgetPassRequest request= new ForgetPassRequest();
		request.setEmail(email);
		ForgotPassResponse response= json.forgotPass(request);
		for(ClassifiedListener mListener:listeners){
			mListener.finishSentForgotPassWord(response.getReturnCode(), response.getDetail());
		}
		
	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for(ClassifiedListener mListener:listeners){
			mListener.finishSentForgotPassWord(IProtocol.STATUS_CODE_GENERICFAIL_500, "");
		}
	}

}
